package com.ys.controller.web.sys;

import com.ys.config.MenuId;
import com.ys.entity.finance.TbCompanyBankInfoAccount;
import com.ys.entity.finance.TcwWanliPaymentReturn;
import com.ys.entity.sys.TbCompanyBankInfo;
import com.ys.entity.sys.YsMenuNo;
import com.ys.mapper.sys.YsMenuNoMapper;
import com.ys.service.sys.CommonApiService;
import com.ys.vo.W;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/web/sys/tbCompanyBankInfoAccount")
public class WebTbCompanyBankInfoAccountController {
	

	@Autowired
	private CommonApiService<TbCompanyBankInfoAccount> commonApiService;

	@Resource
	private YsMenuNoMapper ysMenuNoMapper;


	/*
	 * 新增
	 */
	@GetMapping("/toAdd")
	public String toAdd(Model model, HttpServletRequest request, HttpServletResponse response,@RequestParam Map<String, Object> params){
//		try {
//			Long id = Long.valueOf((params.get("id").toString()));
//
//			TbCompanyBankInfoAccount tbCompanyBankInfoAccount = new TbCompanyBankInfoAccount()
//					.setStatus(1)
//					.setPid()
//					.setId(id)
//					.setCreateTime(new Date());
//
//			return commonApiService.toAdd(model,tbCompanyBankInfoAccount, MenuId.TB_CompanyBankInfoAccount, null, null);
//		} catch (Exception e) {
//			e.printStackTrace();
//			return W.error(model, "数据有误，请联系客服");
//		}
		if (params.get("id") == null){
			return W.error(model, "id不能为空");
		}

		Long id = Long.valueOf((params.get("id").toString()));

		Map<String, Object> extraParam = new TbCompanyBankInfoAccount().setId(id)
				.addLeftJoin("TB_CompanyBankInfo B on  B.Id = A.Pid")

				.queryFirstMap();
		if (extraParam == null){
			return W.error(model, "该公司银行信息不存在!");
		}

		try {
			return commonApiService.toAdd(model, new TbCompanyBankInfoAccount().setStatus(1), MenuId.TB_CompanyBankInfoAccount, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			return W.error(model, "数据有误，请联系客服");
		}
	}





}
